package com.da.javatest.interview.session3;

/**
 * @author JokerDa.
 * @date 2020/12/26 12:14
 * Description:intern()有常量池则返回常量池创建过的 无则创建放到常量池
 * java为false是因为sun.misc.Version里面启动的时候已经创建过了 所以两个对象不同
 */
public class Test01String {
    public static void main(String[] args) {
        String s1 = new StringBuilder("Joker").append("Da").toString();
        System.out.println(s1);
        System.out.println(s1.intern());
        System.out.println(s1 == s1.intern());

        System.out.println();

        String s2 = new StringBuilder("ja").append("va").toString();
        System.out.println(s2);
        System.out.println(s2.intern());
        System.out.println(s2 == s2.intern());
    }
}
